package main

import "fmt"

//结构体1
type Book struct {
	Id    int
	Name  string
	Phone string
}

func main() {
	// 声明并赋值
	var book1 Book
	book1.Id = 1
	book1.Name = "nanfeng"
	book1.Phone = "15252345524"

	//声明并初始化
	book2 := Book{1, "lanting", "15252345524"}
	fmt.Println(book1, book2)
	fmt.Printf("type of %v", book1)

	//访问结构体元素
	fmt.Println(book1.Name, book2.Name)

	// 值传递修改不了结构体的值
	update(book1)
	fmt.Println(book1)

	//指针才能修改结构体的值
	changeByPoint(&book2)
	fmt.Println(book2)

}

func update(params Book) {
	params.Name = "mingquan"
}

func changeByPoint(params *Book) {
	params.Name = "quan"
}
